package com.danjinwulian.device.service.impl;

import java.util.List;

import com.danjinwulian.common.core.domain.entity.IotTenantPower;
import com.danjinwulian.common.utils.DateUtils;
import com.danjinwulian.device.mapper.IotTenantPowerMapper;
import com.danjinwulian.device.service.IIotTenantPowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 住客用电Service业务层处理
 * 
 * @author ken.h
 * @date 2022-08-23
 */
@Service
public class IotTenantPowerServiceImpl implements IIotTenantPowerService
{
    @Autowired
    private IotTenantPowerMapper iotTenantPowerMapper;

    /**
     * 查询住客用电
     * 
     * @param tenantPowerId 住客用电主键
     * @return 住客用电
     */
    @Override
    public IotTenantPower selectIotTenantPowerByTenantPowerId(Long tenantPowerId)
    {
        return iotTenantPowerMapper.selectIotTenantPowerByTenantPowerId(tenantPowerId);
    }

    /**
     * 查询住客用电列表
     * 
     * @param iotTenantPower 住客用电
     * @return 住客用电
     */
    @Override
    public List<IotTenantPower> selectIotTenantPowerList(IotTenantPower iotTenantPower)
    {
        return iotTenantPowerMapper.selectIotTenantPowerList(iotTenantPower);
    }

    /**
     * 新增住客用电
     * 
     * @param iotTenantPower 住客用电
     * @return 结果
     */
    @Override
    public int insertIotTenantPower(IotTenantPower iotTenantPower)
    {
        iotTenantPower.setCreateTime(DateUtils.getNowDate());
        return iotTenantPowerMapper.insertIotTenantPower(iotTenantPower);
    }

    /**
     * 修改住客用电
     * 
     * @param iotTenantPower 住客用电
     * @return 结果
     */
    @Override
    public int updateIotTenantPower(IotTenantPower iotTenantPower)
    {
        iotTenantPower.setUpdateTime(DateUtils.getNowDate());
        return iotTenantPowerMapper.updateIotTenantPower(iotTenantPower);
    }

    /**
     * 批量删除住客用电
     * 
     * @param tenantPowerIds 需要删除的住客用电主键
     * @return 结果
     */
    @Override
    public int deleteIotTenantPowerByTenantPowerIds(Long[] tenantPowerIds)
    {
        return iotTenantPowerMapper.deleteIotTenantPowerByTenantPowerIds(tenantPowerIds);
    }

    /**
     * 删除住客用电信息
     * 
     * @param tenantPowerId 住客用电主键
     * @return 结果
     */
    @Override
    public int deleteIotTenantPowerByTenantPowerId(Long tenantPowerId)
    {
        return iotTenantPowerMapper.deleteIotTenantPowerByTenantPowerId(tenantPowerId);
    }

    @Override
    public List<IotTenantPower> takePowerDate(Long deviceId) {
        return iotTenantPowerMapper.takePowerDate(deviceId);
    }

    @Override
    public List<IotTenantPower> savePowerDate(IotTenantPower tenantPower) {
        return iotTenantPowerMapper.savePowerDate(tenantPower);
    }
    @Override
    public IotTenantPower savePowerDuration(IotTenantPower tenantPower) {
        return iotTenantPowerMapper.savePowerDuration(tenantPower);
    }

    @Override
    public List<IotTenantPower> usePowerRecord(IotTenantPower tenantPower) {
        return iotTenantPowerMapper.usePowerRecord(tenantPower);
    }
}
